﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EZCRS.HCMS.Bll;
using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Entity;

namespace EZCRS.HCMS.Web.manage.hotel
{
    public partial class taxadd : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.BasHotelId == 0)
                Response.Write(CFun.AlertMeg(Resources.Site.MustHotel, "back", ""));

            if (!Page.IsPostBack)
            {
                CFun.SetListControl(ddlFeeType, Bllbase_info.getbaseinfo(baseinfotype.税金类型, CFun.CurrentLanguage()), "");
                CFun.SetListControl(ddlCode, Bllbase_info.getbaseinfo(baseinfotype.税金种类, CFun.CurrentLanguage()), "");
                CFun.SetListControl(ddlAunit, Bllbase_info.getbaseinfo(baseinfotype.货币金额类型, CFun.CurrentLanguage()), "");
                CFun.SetListControl(ddlApplication, Bllbase_info.getbaseinfo(baseinfotype.税金频率, CFun.CurrentLanguage()), "");

                btnsave.Text = Resources.Site.ButtonSave;

                int id = CFun.RequestNumber("id");
                if (id > 0)
                {
                    HCRS_TaxRule _tax = new BllHCRS_Tax().getitem(id);
                    CFun.bindpagedata<HCRS_TaxRule>(this, _tax);

                    btnsave.Text = Resources.Site.ButtonModify;
                    btndel.Visible = true;
                    btndel.Attributes.Add("onclick", "return confirm('" + Resources.Site.SystemConfirmDelete + "');");
                }
            }
        }

        protected void btnsave_Click(object sender, EventArgs e)
        {
            HCRS_TaxRule _tax = new HCRS_TaxRule();
            CFun.getpagedata<HCRS_TaxRule>(_tax, this);
            _tax.Property_id = base.BasPropertyId;
            _tax.userid = base.BasUserId;
            _tax.updatetime = DateTime.Now;
            _tax.languagetype = base.LanguageId;

            if (new BllHCRS_Tax().insertorupdateitem(_tax))
                Page.ClientScript.RegisterClientScriptBlock(typeof(String), "scuress", CFun.AlertMeg(Resources.Site.SystemModifySuccess, "", "tax.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
        }

        protected void btndel_Click(object sender, EventArgs e)
        {
            if(new BllHCRS_Tax().deleteitem(Convert.ToInt32(hidid.Value)))
                Response.Write(CFun.AlertMeg(Resources.Site.SystemDeleteSuccess, "", "tax.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
        }
    }
}
